package cate.game.admin.menu.pvp;

import cate.game.GameBody;
import cate.game.admin.menu.MenuSetup;

import java.util.Arrays;
import java.util.Collections;

import static cate.game.pvp.minecraft.MinecraftMessagingModule.CrossGMCmdType.*;

public class MinecraftMenu extends MenuSetup {

    public MinecraftMenu(GameBody game) {
        super("灵能矿洞");

        reg(game, "采矿区-生成挂机奖励", 3, "[参数1]矿所在层 [参数2]矿配置ID [参数3]分钟数", (role, params) -> {
            if (params.size() < 3) {
                return;
            }
            int layer = toInt(params, 0, 0);
            int tid = toInt(params, 1, 0);
            int minute = toInt(params, 2, 0);
            if (minute <= 0) {
                return;
            }
            game.pvp.minecraft.getMessagingModule().sendGMParams(role, HANG_REWARD_GENERATE,
                    Arrays.asList(String.valueOf(layer), String.valueOf(tid), String.valueOf(minute)));
        });

        reg(game, "采矿区-全部结算", 0, "", (role, params) -> {
            game.pvp.minecraft.getMessagingModule().sendGMParams(role, FORCE_SETTLE,
                    Collections.emptyList());
        });

        reg(game, "采矿区-取消锁定", 2, "[参数1]矿所在层 [参数2]矿配置ID", (role, params) -> {
            if (params.size() < 2) {
                return;
            }
            int layer = toInt(params, 0, 0);
            int tid = toInt(params, 1, 0);
            game.pvp.minecraft.getMessagingModule().sendGMParams(role, CANCEL_LOCK,
                    Arrays.asList(String.valueOf(layer), String.valueOf(tid)));
        });

        reg(game, "采矿区-数据存储", 0, "", (role, params) -> {
            game.pvp.minecraft.getMessagingModule().sendGMParams(role, SAVE,
                    Collections.emptyList());
        });

        reg(game, "合服结算", 0, "", (role, params) -> {
            game.pvp.minecraft.handleMergeSettle();
        });
    }
}
